<?php 
class block1
{
	var $db;
	var $table;
	var $pages;
	var $log;
	var $priv_role;

    function __construct()
    {
		global $db;
		$this->db = &$db;
		$this->table = DB_PRE.'block';
    }

	function block()
	{
		$this->__construct();
	}

	function get($blockid, $fields = '*')
	{
		$blockid = intval($blockid);
		$r = $this->db->get_one("SELECT $fields FROM `$this->table` WHERE `blockid`=$blockid");
		if(!$r) return false;
		return $r;
	}

	function add($info, $roleids = array())
	{
		if($info['name'] == '') return false;
        $info['blockno'] = intval($info['blockno']);
        $info['isarray'] = intval($info['isarray']);
		$this->db->insert($this->table, $info);
		return $blockid;
	}


	function update($blockid, $info)
	{
		$this->db->update($this->table, $info, "`blockid`='$blockid'");
		return true;
	}

}
?>